<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />

  <title>箭头消消消， 360小游戏，好玩的都在这</title>
  <meta name="viewport"
    content="width=device-width,user-scalable=no,initial-scale=1,minimum-scale=1,maximum-scale=1,minimal-ui=true" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="full-screen" content="yes" />
  <meta name="screen-orientation" content="portrait" />
  <meta name="x5-fullscreen" content="true" />
  <meta name="360-fullscreen" content="true" />

  <meta name="renderer" content="webkit" />
  <meta name="force-rendering" content="webkit" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

  <link rel="stylesheet" type="text/css" href="style.css" />
  <link rel="icon" href="favicon.ico" />
  <!--开始引入360橱窗和信息流及激励视频广告sdk，sdk放置在head为了保证广告全局函数能够及时在游戏生命周期中获取到-->
  <script src="//static.mediav.com/js/minigamead.min.js"></script>
  <script src="//static-ssl.mediav.com/js/reward_video_pc.min.js"></script>
  <!--结束引入360橱窗和信息流及激励视频广告sdk-->
  <script>
    var gameParamObj = {
      gameName: "箭头消消消",
      gameId: "759",
      qid: "",
      hasReal: "",
      epso: "",
      ad_adverid: "",
      srcid: "",
    }
    var getparam = function (url) {
      if (url && url.includes("?")) {
        var parmobj = {},
          urlStr = url.split("?")[1],
          queryStr = urlStr.split("&")[1] ? urlStr.split("&") : [urlStr],
          oneQueryStr,
          urlParmKey
        for (urlParmKey in queryStr) {
          oneQueryStr = queryStr[urlParmKey].split("=")
          parmobj[oneQueryStr[0]] = decodeURIComponent(oneQueryStr[1])
        }
        return parmobj
      } else {
        return {}
      }
    }
    gameParamObj = Object.assign(gameParamObj, getparam(location.href))
  </script>
</head>

<body>
  <div id="GameDiv" cc_exact_fit_screen="true">
    <div id="Cocos3dGameContainer">
      <canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="99"></canvas>
    </div>
  </div>

  <!-- Polyfills bundle. -->
  <script src="src/polyfills.bundle.js" charset="utf-8"> </script>

  <!-- SystemJS support. -->
  <script src="src/system.bundle.js" charset="utf-8"> </script>

  <!-- Import map -->
  <script src="src/import-map.json" type="systemjs-importmap" charset="utf-8"> </script>

  <script>
    System.import('./index.js').catch(function (err) { console.error(err); })
  </script>

  <!--开始橱窗和信息流广告样式和dom初始化以及广告拉取填充的业务逻辑-->
  <script>
    //初始化开屏广告样式，创建广告区域dom
    let doc = window.document
    // let divAd = doc.createElement("div")
    // divAd.setAttribute("id", "frontAdBox")
    // divAd.setAttribute(
    //   "style",
    //   "position: absolute;top: 0;bottom: 0;left: 0;right: 0;"
    // )

    let divAdOnce = doc.createElement("divAdOnce")
    divAdOnce.setAttribute("id", "frontAdBoxOnce")
    divAdOnce.setAttribute(
      "style",
      "position: fixed;top: 0;right: 0;"
    )
    //初始化信息流广告样式，创建广告区域dom，信息流三种位置：吸顶、右侧、底部
    let feedAdBottom = doc.createElement("div")
    feedAdBottom.setAttribute("id", "feedAdBoxBottom")
    let feedAdRightBottom = doc.createElement("div")
    feedAdRightBottom.setAttribute("id", "feedAdBoxRightBottom")
    let feedAdMiddle = doc.createElement("div")
    feedAdMiddle.setAttribute("id", "feedAdBoxMiddle")
    /*信息流广告三种位置样式，三选一*/
    //底部位置
    feedAdBottom.setAttribute(
      "style",
      "position: absolute;left: 0;bottom: 0;"
    )
    //右下位置
    feedAdRightBottom.setAttribute(
      "style",
      "position: absolute;right: 0;bottom: 0;width:400px;"
    )
    //中部浮层位置
    feedAdMiddle.setAttribute("style", "position: absolute;top:50%;right: 0;")

    //插入公共广告样式
    // let styleAd = doc.createElement("style")
    // styleAd.setAttribute("type", "text/css")
    // let cssText = doc.createTextNode(
    //   "#frontAdBox div:first-child {position: absolute !important;top: 50%;left: 50%;transform: translate(-50%, -50%); #feedAdBoxBottom newsfeed {margin: 0 auto !important;}"
    // )
    // styleAd.appendChild(cssText)


    let styleAdOnce = doc.createElement("styleOnce")
    styleAdOnce.setAttribute("type", "text/css")
    let cssTextOnce = doc.createTextNode(
      "#frontAdBoxOnce div:first-child { border-radius: 30px}"
    )
    styleAdOnce.appendChild(cssTextOnce)

    //添加样式文件, 此处建议将所有广告位置放置在主游戏所在dom区域范围内
    let gamebody = doc.querySelector("body")

    gamebody.appendChild(styleAd)
    gamebody.appendChild(divAd)

    gamebody.appendChild(styleAdOnce)
    gamebody.appendChild(divAdOnce)

    gamebody.appendChild(feedAdBottom)
    gamebody.appendChild(feedAdRightBottom)
    gamebody.appendChild(feedAdMiddle)


    let allWidth = 300
    let allHeight = 300
    if (window.document && window.document.body) {
      if (window.document.clientWidth)
        allWidth = window.document.body.clientWidth

      if (window.document.clientHeight)
        allHeight = window.document.body.clientHeight
    }

    // 插屏
    // MINIGAMEAD.renderShopWindow({
    //   showid: "sL9Jkr", //橱窗广告位id
    //   adDomId: "frontAdBox", //广告区域domid
    //   width: "380", //广告宽
    //   height: "380", //广告高
    // })

    // // 右上角小icon
    // MINIGAMEAD.renderShopWindow({
    //   showid: "sL9Jkr", //橱窗广告位id
    //   adDomId: "frontAdBoxOnce", //广告区域domid
    // })

    // banner
    // MINIGAMEAD.renderInfoFlow({
    //   showid: "G85el5", //信息流广告位id
    //   adDomId: "feedAdBoxBottom", //底部信息流广告区域domid
    //   width: allWidth + "", //广告宽
    //   onSuccess: (res) => {
    //     console.log(1, res)
    //   },
    //   onFail: (res, res2) => {
    //     console.log(2, res, res2)
    //   }
    // })
    //     MINIGAMEAD.renderInfoFlow({
    //     showid: '0****O',//信息流广告位id
    //     adDomId: 'feedAdBoxRightBottom',//右下位置信息流广告区域domid
    //     width: '300',//广告宽
    // });
    // MINIGAMEAD.renderInfoFlow({
    //   showid: 'G85el5',//信息流广告位id
    //   adDomId: 'feedAdBoxMiddle',//中部信息流广告区域domid
    //   width: '300',//广告宽
    // });


    //  开屏
    // MINIGAMEAD.renderShopWindow({ showid: "zr6f4v", adDomId: "frontAdBox", width: allWidth + "", height: allHeight + "", });

    // 激励视频
    // const RewardedVideoAd = REWARD_VIDEO_AD.createRewardedVideoAd({
    //   adUnitId: "kWfCcl",
    // });
    // RewardedVideoAd.onLoad(() => {
    //   console.log("视频加载成功");

    //   RewardedVideoAd.show()
    //   .catch(() => {
    //     RewardedVideoAd.load()
    //       .then(() => {
    //         RewardedVideoAd.show()
    //       })
    //       .catch(_err => { })
    //   })
    // });
    // RewardedVideoAd.onError(err => {
    //   if (err) {
    //     console.error(err.errMsg);
    //   }
    // });
    // RewardedVideoAd.onClose(res => {
    //   console.log("视频关闭");
    //   if (res) {
    //     console.log("是否完整播放：" + res.isEnded);
    //     console.log("播放时间：" + res.currentTime);
    //     console.log("广告总时间：" + res.duration);
    //   }
    // });

    console.log = function () {

    }


  </script>
  <!--结束橱窗和信息流广告样式和dom初始化以及广告拉取填充的业务逻辑-->
  <script>
      ; (function (b, a, e, h, f, c, g, s) {
        b[h] =
          b[h] ||
          function () {
            ; (b[h].c = b[h].c || []).push(arguments)
          }
        b[h].s = !!c
        g = a.getElementsByTagName(e)[0]
        s = a.createElement(e)
        s.src = "//s.union.360.cn/" + f + ".js"
        s.defer = !0
        s.async = !0
        g.parentNode.insertBefore(s, g)
      })(window, document, "script", "_qha", 528396, false) // 替换为自己的分析站点id
  </script>
  <!--开始自动打点调用-->
  <script>
    var isStart = true
    // uv上报
    _qha("send", {
      et: 11,
      gameName: gameParamObj.gameName,
      gameId: gameParamObj.gameId,
      qid: gameParamObj.qid,
      hasReal: gameParamObj.hasReal,
      ep: "funUser",
    })
    // 归因参数、pv上报
    _qha("send", {
      et: 11,
      gameName: gameParamObj.gameName,
      gameId: gameParamObj.gameId,
      qid: gameParamObj.qid,
      hasReal: gameParamObj.hasReal,
      epso: gameParamObj.sourceid,
      ad_adverid: gameParamObj.ad_adverid,
      srcid: gameParamObj.srcid,
      fxext: { type: 2, type_d: 4 },
      ep: "gamePv",
    })
    /* 开始游戏上报
     * 游戏没有开始按钮的，通过canvas内的第一次点击模拟 ep=firstClick 作为开始游戏的打点上报
     * 游戏自身有开始按钮的，根据自身业务调用实现 ep=start 作为开始游戏的打点上报
     */
    if (document.getElementsByTagName("canvas").length) {
      document.getElementsByTagName("canvas")[0].onclick = function () {
        if (!isStart) return
        _qha("send", {
          et: 11,
          gameName: gameParamObj.gameName,
          gameId: gameParamObj.gameId,
          qid: gameParamObj.qid,
          hasReal: gameParamObj.hasReal,
          epso: gameParamObj.sourceid,
          ad_adverid: gameParamObj.ad_adverid,
          srcid: gameParamObj.srcid,
          fxext: { type: 2, type_d: 4 }, // 固定格式，不用改
          funOrder: 4, // 固定格式，不用改
          ep: "firstClick", // 固定格式，不用改
        })
        isStart = false
      }
    }
  </script>
  <!--结束自动打点调用-->
</body>

</html>